﻿

using Maticsoft.BLL;
using Maticsoft.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class WebPage_SheZhi_Pifu : SystemBBasePage
{
    private string[] filenames;
    private List<string> fileNames = new List<string>();
    private Maticsoft.Model.System system = new Maticsoft.Model.System();
    private Maticsoft.BLL.System systems = new Maticsoft.BLL.System();

    private List<string> getNextTest(string srcPath)
    {
        List<string> list = new List<string>();
        string[] fileSystemEntries = Directory.GetFileSystemEntries(srcPath);
        foreach (string str in fileSystemEntries)
        {
            if (Directory.Exists(str))
            {
                list.Add(str);
            }
        }
        return list;
    }

    private string getText()
    {
        return HttpContext.Current.Server.MapPath("/upfile/theme");
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.HeaderControl1.Select = "shezhi";
        if (base.Request.HttpMethod == "POST")
        {
            this.TextAdd();
        }
        this.setText();
    }

    private void setText()
    {
        this.fileNames = this.getNextTest(this.getText());
        StringBuilder builder = new StringBuilder();
        string skintheme = string.Empty;
        if (base.ASSystem != null)
        {
            skintheme = base.ASSystem.skintheme;
        }
        if (this.fileNames != null)
        {
            this.system = this.systems.GetModel(1);
            builder.Append("<select name='theme' class='f-input' style='width:200px;'>");
            for (int i = 0; i < this.fileNames.Count; i++)
            {
                string[] strArray = this.fileNames[i].Split(new char[] { '\\' });
                if (skintheme == this.fileNames[i])
                {
                    builder.Append("<option  value='" + strArray[strArray.Length - 1].ToString() + " ' >" + strArray[strArray.Length - 1].ToString() + "</option>");
                }
                else if (this.system.skintheme == strArray[strArray.Length - 1].ToString())
                {
                    builder.Append("<option  value='" + strArray[strArray.Length - 1].ToString() + "' selected>" + strArray[strArray.Length - 1].ToString() + "</option>");
                }
                else
                {
                    builder.Append("<option  value='" + strArray[strArray.Length - 1].ToString() + "' >" + strArray[strArray.Length - 1].ToString() + "</option>");
                }
            }
            if (this.system.skintheme == string.Empty)
            {
                builder.Append("<option value='' selected >默认皮肤</option>");
            }
            else
            {
                builder.Append("<option value='' >默认皮肤</option>");
            }
            builder.Append("</select> ");
        }
        this.Literal1.Text = builder.ToString();
    }

    private void TextAdd()
    {
        if (base.Request.Form["theme"].ToString() != "-1")
        {
            this.system = this.systems.GetModel(1);
            this.system.skintheme = base.Request.Form["theme"].ToString();
            this.systems.Update(this.system);
        }
        base.SetSuccess("设置成功");
    }
}

